<?php
$config_file = parse_ini_file("../../properties/config.ini");
$include_path = "../";
include_once("../util/log_writer.php");
require_once("emaillib.php");
$lw = LogWriter::getInstance("../../properties/log4php-level2.properties");
$function = $_POST["func"];
$response = "";
$lw->debug("function=" . $function);
	
try {
	if ($function == "L") {//list
	$lw->debug("getting messages");
		$response = Email::getMessages(intval($_POST["pageNo"]));
	$lw->debug("got messages");
	} else if ($function == "M") {//mark read
	$lw->debug("marking read for " . $_POST["email_id"]);
		$response = Email::markRead(intval($_POST["email_id"]));
	$lw->debug("marked read");
	} else if ($function == "D") {//delete
	$lw->debug("deleting messages");
		$response = Email::deleteMessages($_POST["email_id"]);
	$lw->debug("deleted messages");
	}
} catch (Exception $e) {
	print var_dump($e);
}
	$lw->debug("processing response");
	include("admin_data_reponse.php");
	$lw->debug("processed response");
?>
